package com.xuelang.pipeline.app.resource;

import com.xuelang.pipeline.app.resource.impl.DynamicPodServiceFallbackImpl;
import com.xuelang.pipeline.app.resource.request.PodListRequest;
import com.xuelang.pipeline.app.resource.request.PodLogRequest;
import com.xuelang.pipeline.client.common.result.ApiResult;
import feign.Headers;
import feign.RequestLine;
import io.kubernetes.client.openapi.models.V1PodList;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;

import jakarta.validation.Valid;
import java.net.URI;

/**
 * 动态pod服务接口
 *
 * @author xiwen.zxg
 * @since 2024/5/28
 */
@FeignClient(name = "dynamic-pod-service", fallbackFactory = DynamicPodServiceFallbackImpl.class)
public interface DynamicPodService {

    /**
     * 获取pod列表
     *
     * @param uri
     * @param podListRequest
     * @return
     */
    @RequestLine("POST /get/pod/list")
    @Headers("Content-Type: application/json")
    ApiResult<V1PodList> list(URI uri, @RequestBody @Valid PodListRequest podListRequest);

    /**
     * 获取pod日志
     *
     * @param uri
     * @param podLogRequest
     * @return
     */
    @RequestLine("POST /get/pod/log")
    @Headers("Content-Type: application/json")
    ApiResult<String> log(URI uri, @RequestBody @Valid PodLogRequest podLogRequest);

}
